from flask_restplus import Resource, Namespace, fields, marshal_with

from app.routes.user.schemas import user_login, user_id
from common.utils.decorators import login_required
from flask import g, request, jsonify
from common.models import db
from flask_restplus import reqparse, inputs
from app.routes.hello.schemas import hello_mds, post_hello_mds
from app.tasks.test import test

user_ns = Namespace("user")
# hello_ns.schema_model(name=Hello, schema="hello")


class UserLoginView(Resource):

    user_login = user_login(user_ns)
    user_id = user_id(user_ns)

    # method_decorators = {"get": [login_required]} # 检查用户登录的装饰器
    @user_ns.expect(user_login, validate=True)
    @user_ns.marshal_with(user_id)
    def post(self):
        data = request.args
        result = test.delay()

        return data
